<template>
  <el-form label-width="100px">
    <!-- 整体风格 -->
    <el-form-item label="整体风格">
      <el-radio-group v-model="themeMode">
        <el-radio label="light">浅色</el-radio>
        <el-radio label="dark">深色</el-radio>
        <el-radio label="auto">自动</el-radio>
      </el-radio-group>
    </el-form-item>
    <!-- 主题色 -->
    <el-form-item label="主题色">
      <el-radio-group v-model="primaryColor">
        <el-radio label="blue"><span class="color-dot" style="background: #1890ff;"></span></el-radio>
        <el-radio label="purple"><span class="color-dot" style="background: #722ed1;"></span></el-radio>
        <el-radio label="pink"><span class="color-dot" style="background: #eb2f96;"></span></el-radio>
      </el-radio-group>
    </el-form-item>
    <!-- 导航模式 -->
    <el-form-item label="导航模式">
      <el-radio-group v-model="navMode">
        <el-radio label="side">侧边栏模式</el-radio>
        <el-radio label="top">顶部导航模式</el-radio>
      </el-radio-group>
    </el-form-item>
    <!-- 保存按钮 -->
    <el-form-item>
      <el-button type="primary" @click="submitConfig">保存配置</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import { ref, defineEmits } from 'vue'

export default {
  setup() {
    const emits = defineEmits(['update-config']) // 自定义事件，通知父组件更新配置

    // 双向绑定配置项
    const themeMode = ref('light')
    const primaryColor = ref('blue')
    const navMode = ref('side')

    // 提交配置（触发父组件事件）
    const submitConfig = () => {
      emits('update-config', {
        themeMode: themeMode.value,
        primaryColor: primaryColor.value,
        navMode: navMode.value
      })
    }

    return {
      themeMode,
      primaryColor,
      navMode,
      submitConfig
    }
  }
}
</script>

<style scoped>
.color-dot {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
}
</style>

